

<template>
	<view class="mainPage" :style="{'padding-top': `${$store.state.safeArea.top || 0}px`, 'padding-bottom': `${$store.state.safeArea.bottom || 0}px`}">
		<public-head :title="title"></public-head>
		<view class="" v-for="(it,i) in list" :key="i" @click="tiaozhuan(it)">
			<view class="h2 w100pc"></view>
			<view class="lrmg-30 bra20" style="background: #fff;padding: 20rpx;">
				<view class="fsb">
					<view class="flex aic">
						<image :src="it.user_avatar" style="width:64rpx;height:64rpx" class="bra50"></image>
						<view class="mg-l-20" style="color: #0D0E15;width: 150rpx;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">{{it.user_name}}</view>
						<view class="mg-l-20 f24" style="color: #959595;">{{it.race}} {{it.sex}} {{it.weight}}kg</view>
					</view>
					<view class="flex aic">
						<view class="bra60 mg-r-20" style="color: #FA6400;border: 1rpx solid #FA6400;width: 160rpx;height: 60rpx;text-align: center;line-height: 60rpx;">{{it.consultation_name}}</view>
						<view class="" style="color: #ED0B0D;" v-show="it.comment == 0">待评价</view>
						<view class="" style="color: #959595;" v-show="it.comment == 1">已完成</view>
					</view>
				</view>
				<view class="flex mg-t-30">
					<view class="" style="color: #959595;margin-left: 2%;">问题描述：</view>
					<view class="" style="width: 70%;">{{it.describe}}</view>
				</view>
				<view class="mg-t-30" style="margin-left: 2%;color: #959595;">{{it.en_time}}</view>
			</view>
		</view>
		<!-- <view class="item" v-for="(item, index) in list" :key="index">
			{{'第' + item + '条数据'}}
		</view> -->
		<u-loadmore :status="status" v-if="list.length >= 10" />
	</view>
</template> 

<script>
	var that
	import publicHead from "@/components/publicHead/publicHead.vue"
	export default {
		components: {
			publicHead
		},
		data(){
			return{
				title: '问诊记录',
				order:{},
				list:[],
				status: 'loadmore',
				page: 1,
				time:'',
				page_count:''
			}
		},
		onReachBottom() {
			if(that.page == that.page_count){
				that.status = 'nomore'
				return
			}
			that.status = 'loading';
			that.page = ++ that.page;
			let postData = {
				user_id:that.order.uid,
				page:that.page,
				pagesize:10,
				time:that.time
			}
			that.$postAjax1('DoctorGroup_getUserOrderList',postData,function(data){
				console.log(data.data.data,'已完成问诊记录');
				data = data.data.data
				setTimeout(() => {
					that.list = that.list.concat(data.data)
					that.page = data.page_list.page//当前页
					that.page_count = data.page_list.page_count//总页数
					that.status = 'loadmore'
				}, 500)
			})
		},
		onLoad(options) {
			that = this
			that.order = JSON.parse(options.item)
			console.log(that.order);
			uni.setNavigationBarTitle({
			    title: that.order.nickname
			});
			that.get()
		},
		methods:{
			get(){
				that.time = Math.round(new Date() / 1000)
				let postData = {
					user_id:that.order.uid,
					page:that.page,
					pagesize:10,
					time:that.time
				}
				that.$postAjax1('DoctorGroup_getUserOrderList',postData,function(data){
					console.log(data.data.data,'已完成问诊记录');
					data = data.data.data
					that.list = data.data
					that.page = data.page_list.page//当前页
					that.page_count = data.page_list.page_count//总页数
				})
			},
			tiaozhuan(item){
				uni.navigateTo({
					url:'detail?item=' + JSON.stringify(item) +'&type=1'
				})
			}
		}
	}
</script>